<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>mtlb_max</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>M2SCI function</center>
    <div align="right">Last update : 08/04/2004</div>
    <p>
      <b>mtlb_max</b> - Matlab max emulation function</p>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>Matlab and Scilab <tt>
        <b>max</b>
      </tt> behave differently in some particular cases:</p>
    <dl>
      <dd>
        <b></b>
        <dd>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        With complex values: Matlab <tt>
              <b>max</b>
            </tt> can be used with complex values but not Scilab function.
        </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        When called with one input: Matlab <tt>
              <b>max</b>
            </tt> threats values along the first
	non-singleton dimension but Scilab threats all input values.
        </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        When called with two inputs: if one is an empty matrix, Scilab returns an error message but Matlab returns [].
        </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        When called with three inputs: if <tt>
              <b>dim</b>
            </tt> parameter is greater than number of
	dimensions of first input, Scilab returns an error message and Matlab returns the first input.
        </li>
        </dd>
      </dd>
    </dl>
    <p>
    The function <tt>
        <b>[r[,k]] = mtlb_max(A[,B[,dim]])</b>
      </tt> is used by
    <tt>
        <b>mfile2sci</b>
      </tt> to replace <tt>
        <b>[r[,k]] = max(A[,B[,dim]])</b>
      </tt> when it was not
    possible to know what were the inputs while porting Matlab code to Scilab. This function will
    determine the correct semantic at run time. If you want to have a
    more efficient code it is possible to replace <tt>
        <b>mtlb_max</b>
      </tt> calls:
    </p>
    <dl>
      <dd>
        <b></b>
        <dd>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        When called with one input, if <tt>
              <b>A</b>
            </tt> is a vector or a scalar
        <tt>
              <b>[r[,k]] = mtlb_max(A)</b>
            </tt> may be replaced by <tt>
              <b>max(A)</b>
            </tt>
          </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        When called with one input, if <tt>
              <b>A</b>
            </tt> is a matrix
        <tt>
              <b>[r[,k]] = mtlb_max(A)</b>
            </tt> may be replaced by <tt>
              <b>max(A,"r")</b>
            </tt>
          </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        When called with two inputs, if <tt>
              <b>A</b>
            </tt> and <tt>
              <b>B</b>
            </tt> are real matrices and not empty matrices
        <tt>
              <b>[r[,k]] = mtlb_max(A,B)</b>
            </tt> may be replaced by <tt>
              <b>max(A,B)</b>
            </tt>
          </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        When called with three inputs, if <tt>
              <b>dim</b>
            </tt> is lesser than the number of dimensions of <tt>
              <b>A</b>
            </tt>
            <tt>
              <b>[r[,k]] = mtlb_max(A,[],dim)</b>
            </tt> may be replaced by <tt>
              <b>max(A,dim)</b>
            </tt>
          </li>
        </dd>
      </dd>
    </dl>
    <p>Caution: <tt>
        <b>mtlb_max</b>
      </tt> has not to be used for hand coded functions.</p>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="firstnonsingleton.htm">
        <tt>
          <b>firstnonsingleton</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Authors</font>
    </h3>
    <dl>
      <dd>
        <b></b>V.C.</dd>
    </dl>
  </body>
</html>
